Added method so that SrvDaemon can be run in the foreground without all the
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Mon, 21 Nov 2005 11:44:43 +0000 (12:44 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Mon, 21 Nov 2005 11:44:43 +0000 (12:44 +0100)
forking implied by the start method.  This makes it easier to run valgrind
against Xend, or run it with a pydebug-compiled Python.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/server/SrvDaemon.py

index 5c1a8f7f693b1a6f69f58cceabb6f6211d221c80..faa075767ae661551809f7452ca8435d506f7774 100644 (file)
@@ -300,3 +300,25 @@ def instance():
     except:
         inst = Daemon()
     return inst
+
+
+def main(argv = None):
+    global XEND_DAEMONIZE
+    
+    XEND_DAEMONIZE = 0
+    if argv is None:
+        argv = sys.argv
+
+    try:
+        daemon = instance()
+    
+        r,w = os.pipe()
+        daemon.run(os.fdopen(w, 'w'))
+        return 0
+    except Exception, exn:
+        log.fatal(exn)
+        return 1
+
+
+if __name__ == "__main__":
+    sys.exit(main())